package finalproject.model.rooms;

import finalproject.config.Randomizer;
import finalproject.model.items.OopBook;
import finalproject.model.player.Player;
import finalproject.view.StringManager;

/**
 * The library
 * @author Yassine Tijani
 *
 */
public class Library extends Room {
    
	/**
	 * The oop book you will find at the library
	 */
    private OopBook book;

    /**
     * @param description the room description
     */
    public Library(String description) {
        super(description,true);
        // TODO Auto-generated constructor stub
    }

    
    @Override
    public boolean doActivity(Player p) {
        if(this.book == null)
        {
            return false;
        }
        else if(p.getItemHolder().addItem(this.book))
        {
            return true;
        }
        else
        {
            return false;
        }
    }


    @Override
    public boolean prepareActivity(Player p) {
        if(Randomizer.getRandom().nextInt(100) == 1)
        {
            this.book = OopBook.getInstance();
            return true;
        }
        else
        {
            this.book = null;
            return false;
        }
    }
    
    @Override
	public String toString()
    {
        if(this.book == null)
        {
        return super.toString() + " : " + StringManager.getString("nobook");
        }
        else
        {
        return super.toString() + " : " + StringManager.getString("book");
        }
    }

}
